package com.project.controller.addressController;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.bean.AddressBean;
import com.project.service.addressService.IAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/address")
public class AddressController {
    @Autowired
    private IAddressService service;

    @RequestMapping("/findAll")
    public PageInfo<AddressBean> findAll(int pageNO,int userId){
        return service.findAll(pageNO, userId);
    }

    @RequestMapping("/getAll")
    public List<AddressBean> getAll(int userId){
        return service.getAll(userId);
    }

    @RequestMapping("/add")
    public String add(AddressBean addressBean,int userId){
        service.add(addressBean,userId);
        return "ok";
    }
    @RequestMapping("/del")
    public String del(int id){
        service.del(id);
        return "ok";
    }
    @RequestMapping("update")
    public String update(int id,String name,String tel, String address){
        service.update(id, name, tel,address);
        return "ok";
    }
}
